<template>
	<view class="container">

		<view class="header-title-box">
			<!-- :style="{background:'url('+infoModel.backgroundImage+') no-repeat',backgroundSize: 'cover','backgroundColor':'#666'}" -->
			<view class="header-top">
				<view class="header-top-left"><img
						:src="avatarUrl ? avatarUrl : 'https://picx.zhimg.com/v2-8d117f237079440cc59baf9ca762d29f_r.jpg?source=1940ef5c'"
						alt="" />
				</view>
				<view class=" header-top-right">
					<view style="font-size: 36rpx">{{ infoModel.weUserName }}</view>
					<view style="font-size: 28rpx">IP属地：{{
              infoModel.locationName ? infoModel.locationName : "未知"
            }}</view>
				</view>
			</view>
			<view class="header-bottom">
				<view class="header-bottom-left">
					<view>学历：{{
              infoModel.education ? infoModel.education : "暂无"
            }}</view>
					<view>职业：{{
              infoModel.profession ? infoModel.profession : "暂无"
            }}</view>
					<!-- <view>关注：203</view> -->
					<!-- <view>老家：山东</view> -->
				</view>
				<view class="header-bottom-right">
					<view style="
              padding: 10rpx 20rpx;
              border-radius: 10rpx;
              border: 2rpx solid #fff;
            " @click="editInfo">编辑资料</view>
				</view>
			</view>
			<!-- <img v-if='infoModel.backgroundImage' :src="infoModel.backgroundImage"
				style="position: absolute; width: 100%;height: 100%;top: 0;left: 0;" alt=""> -->
		</view>
		<view class="btn-box">
			<!-- 	<view class="img-box">
				<img :src="baseURL + '/static/space/icon-wdkj.png'" alt="" />
			</view> -->
			<u-button type="primary" color="#216be6" @click="publishClick" icon="plus-circle" text="发布"></u-button>
		</view>
		<view class="content-box">
			<scroll-view style="height: 100vh" scroll-y="true" class="scroll-Y" @scrolltolower="scrolltolower">
				<view class="space-list">
					<view class="space-item" v-for="item in dynamicList" :key="item">
						<view class="box-bg">
							<view class="img-list" @click="detailClick(item)">
								<view class="img-item">
									<img :src="
                      item.coverImage
                        ? item.coverImage
                        : baseURL + '/static/error.png'
                    " alt="" />
								</view>
							</view>
							<view class="content-text">
								{{ item.title }}
							</view>
							<view class="header-box">
								<view class="header-left">
									<view class="header-sculpture-box">
										<img :src="item.weAvatar" alt="" />
									</view>
									<view style="font-size: 28rpx">
										{{ item.weUserName }}
									</view>
								</view>
								<view class="header-right">
									<view class="right-cion">
										<view class="right-cion"><u-icon size="36rpx"
												name="heart"></u-icon>{{ item.likeQuantity }}</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view style="height: 100rpx">
					<u-loadmore :status="status" />
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		dynamic
	} from "@/api/axios/Space.js";
	import {
		info
	} from "@/api/axios/center.js";
	export default {
		data() {
			return {
				openId: "",
				visitOpenId: "",
				baseURL: this.staticURL,
				pageNo: 1,
				pageSize: 20,
				dynamicList: [],
				status: "loadmore",
				avatarUrl: "",
				infoModel: {},
			};
		},
		methods: {
			editInfo() {
				uni.navigateTo({
					url: "/pages-center/PersonalInformation/index",
				});
			},
			publishClick() {
				uni.redirectTo({
					url: "/pages-space/SpacePublish/index",
				});
			},

			editMethod() {},
			scrolltolower() {
				let _this = this;
				if (this.status !== "nomore" && this.status !== "loading") {
					this.status = "loading";
					dynamic({
						params: {
							queryType: "2",
							pageNo: this.pageNo,
							pageSize: this.pageSize,
							openId: this.openId,
						},
					}).then((res) => {
						_this.dynamicList = _this.dynamicList.concat(res.records);
						if (res.records.length > _this.pageSize) {
							_this.pageNo = _this.pageNo + 1;
							_this.status = "loadmore";
						} else {
							_this.status = "nomore";
						}
						console.log(_this.status);
					});
				}
			},
			questionnaireClick() {
				uni.navigateTo({
					url: "/pages-space/Questionnaire/index",
				});
			},
			signInClick() {
				uni.navigateTo({
					url: "/pages-space/SignIn/index",
				});
			},
			myClick() {
				uni.navigateTo({
					url: "/pages-space/MySpace/index",
				});
			},
			detailClick(item) {
				console.log(item);
				item.likeQuantity = item.likeQuantity.toString();
				// let data = uni.$u.queryParams(item)
				uni.navigateTo({
					url: "/pages-space/SpaceDetail/index?id=" + item.id,
				});
			},
			inviteFriendsClick() {
				wx.showShareMenu({
					withShareTicket: true,
					menus: ["shareAppMessage", "shareTimeline"],
				});
			},
			publishClick() {
				uni.navigateTo({
					url: "/pages-space/SpacePublish/index",
				});
			},
		},
		onLoad(options) {
			let openId = uni.getStorageSync("openId");
			this.openId = openId;
			let avatarUrl = uni.getStorageSync("avatarUrl");
			this.avatarUrl = avatarUrl;
			// let _this = this;
			// this.status = "loading";
			// dynamic({
			//   params: {
			//     pageNo: this.pageNo,
			//     pageSize: this.pageSize,
			//     openId: openId,
			//   },
			// }).then((res) => {
			//   _this.dynamicList = res.records;

			//   if (_this.dynamicList.length > _this.pageSize) {
			//     _this.pageNo = _this.pageNo + 1;
			//     _this.status = "loadmore";
			//   } else {
			//     _this.status = "nomore";
			//   }
			// });
		},
		created() {},
		onShow() {
			let _this = this;
			this.status = "loading";
			dynamic({
				params: {
					queryType: "2",
					pageNo: this.pageNo,
					pageSize: this.pageSize,
					openId: this.openId,
				},
			}).then((res) => {
				_this.dynamicList = res.records;
				if (_this.dynamicList.length > _this.pageSize) {
					_this.pageNo = _this.pageNo + 1;
					_this.status = "loadmore";
				} else {
					_this.status = "nomore";
				}
			});

			info({
				params: {
					openId: this.openId,
				},
			}).then((res) => {
				console.log(res);
				_this.infoModel = res;
				// _this.fileList = [{
				// 	url: res.backgroundImage
				// }]
				// _this.infoModel.weAvatar = uni.getStorageSync("avatarUrl");
				// _this.infoModel.weUserName = uni.getStorageSync("nickName");
				// _this.infoModel.wePhone = uni.getStorageSync("phone");
			});
		},
		mounted() {},
	};
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>